import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class SeleniumDemo {

    public static void main(String[] args) throws InterruptedException {
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.12306.cn/index");
        JavascriptExecutor js = (JavascriptExecutor) driver;
        Thread.sleep(5000);
        js.executeScript("document.getElementById('train_date').value='2021-12-28'");
        Thread.sleep(5000);
        System.out.println(js.executeScript("return document.getElementById('train_date').value"));
        driver.quit();
    }

}
